#include <iostream>


//单例模式：一个类只创建一个对象
//1、构造函数私有化
//2、构建静态函数
//3、在函数中定义静态对象，返回静态对象指针
class Singleton
{
public:
    static Singleton* getInstance()
    {
        static Singleton s;
        return &s;
    }
private:
    Singleton(){}
};

int main()
{
    Singleton *t1 = Singleton::getInstance();
    Singleton *t2 = Singleton::getInstance();
    Singleton *t3 = Singleton::getInstance();
    printf("%p %p %p\n",t1,t2,t3);
    return 0;
}